﻿using System;
using Core.Authenticated;
using Core.Library;
using DataObject;
using DataObject.Cache;

namespace CMS.Controls.Config
{
    public partial class ClearCache : AuthenticatedControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void ManagerAction(string action)
        {
            try
            {
                CacheController.RemoveCachePort(action);
                ltMessage.Text = MessageUtility.ShowMessage(string.Empty, "Xóa cache thành công.", MessageType.Success);
            }
            catch (Exception ex)
            {

                ltMessage.Text = MessageUtility.ShowMessage("Lỗi", ex.Message, MessageType.Failure);
            }
        
        }

        protected void btnNews(object sender, EventArgs e)
        {
            ManagerAction(Constants.ManagerCacheGroup.News);
        }

        protected void btnUser(object sender, EventArgs e)
        {
            ManagerAction(Constants.ManagerCacheGroup.User);
        }

        protected void btnPhoto(object sender, EventArgs e)
        {
            ManagerAction(Constants.ManagerCacheGroup.Photo);
        }

        protected void btnQA(object sender, EventArgs e)
        {
            ManagerAction(Constants.ManagerCacheGroup.QA);
        }
        protected void btnVote(object sender, EventArgs e)
        {
            ManagerAction(Constants.ManagerCacheGroup.Vote);
        }
        protected void btnConfig(object sender, EventArgs e)
        {
            ManagerAction(Constants.ManagerCacheGroup.Config);
        }
        protected void btnData(object sender, EventArgs e)
        {
            ManagerAction(Constants.ManagerCacheGroup.Data);
        }

        protected void btnHighlight(object sender, EventArgs e)
        {
            ManagerAction(Constants.ManagerCacheGroup.Highlight);
        }
    }
}